package ooday04;

public class AnimalTest {
    public static void main(String[] args) {
        Animal[] animals=new Animal[5];
        animals[0]=new Dog("小黑",5,"白");
        animals[1]=new Dog("小白",10,"黑");
        animals[2]=new Chick("小黄",3,"黄");
        animals[3]=new Chick("小绿",8,"绿");
        animals[4]=new Fish("金金",2,"金");
        for (int i = 0; i < animals.length; i++) {
            System.out.println(animals[i].name);
            animals[i].eat();
            animals[i].drink();

            if(animals[i] instanceof Dog){
                Dog dog=(Dog)animals[i];
                dog.lookhome();

            }

            if(animals[i] instanceof  Chick){
                Chick chick=(Chick)animals[i];
                chick.egg();
            }
            if(animals[i] instanceof  Swim){
               Swim swim=(Swim) animals[i];
               swim.swim();

            }

        }
















        /*
        Animal[] animals=new Animal[5];
        animals[0]=new Dog("小黑",5,"白");
        animals[1]=new Dog("小白",10,"黑");
        animals[2]=new Chick("小黄",3,"黄");
        animals[3]=new Chick("小绿",8,"绿");
        animals[4]=new Fish("金金",2,"金");

        animals[0].eat();
        animals[1].eat();
        animals[2].eat();
        animals[3].eat();
        animals[4].eat();

        animals[0].drink();
        animals[1].drink();
        animals[2].drink();
        animals[3].drink();
        animals[4].drink();












        Master master= new Master();
        Dog dog=new Dog("小黑",5,"白");
        Chick chick=new Chick("丫丫",3,"黄");
        Fish fish =new Fish("金金",1,"金");

        master.feed(dog);
        master.feed(chick);
        master.feed(fish);


        Dog[] dogs=new Dog[3];
        dogs[0]=new Dog("小黑",5,"黑");
        dogs[1]=new Dog("小灰",2,"灰");
        dogs[2]=new Dog("小白",1,"白");
        System.out.println(dogs[0].name);
        for (int i = 0; i < dogs.length ; i++) {
            System.out.println(dogs[i].name);
            dogs[i].eat();
            dogs[i].drink();
            dogs[i].swim();

        }

        Chick[] chicks=new Chick[3];
        chicks[0]=new Chick("小黄",1,"黄");
        chicks[1]=new Chick("小绿",2,"绿");
        chicks[2]=new Chick("小蓝",5,"蓝");
        for (int i = 0; i < chicks.length ; i++) {
            System.out.println(chicks[i].name);
            chicks[i].eat();
            chicks[i].drink();
            chicks[i].egg();

        }

        Fish[] fish =new Fish[3];
        fish[0]=new Fish("金金",6,"金");
        fish[1]=new Fish("咕咕",3,"红");
        fish[2]=new Fish("哈哈",9,"蓝");
        for (int i = 0; i < fish.length ; i++) {
            System.out.println(fish[i].name);
            fish[i].eat();
            fish[i].drink();
            fish[i].swim();

}
         */

    }
}

